var str = "i am ( name ) {name},I { age } year old";
var str1 = str.match(/\{(.+?)\}/g)
var nstr = str.replace(/\{[^\}]*\}/g, "99");
console.log(nstr, str1[0].substring(1, str1[0].length - 1))